﻿Imports System
Imports System.Collections.Generic
Imports System.Globalization
Imports System.IO
Imports System.Workflow.ComponentModel
Imports System.Workflow.Runtime
Imports System.Xml
Imports System.Xml.Schema

Namespace System.Workflow.Runtime.Tracking
    Public Class TrackingProfileSerializer
        ' Methods
        Public Sub New()
            Me._schema.Namespaces.Add("", "http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile")
        End Sub

        Private Sub CheckSchemaErrors()
            If Me._vex Then
                Dim exception As New TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationSchemaError)
                If (Not Me._vArgs Is Nothing) Then
                    Dim args As ValidationEventArgs
                    For Each args In Me._vArgs
                        exception.ValidationEventArgs.Add(args)
                    Next
                End If
                Throw exception
            End If
        End Sub

        Private Sub CreateActivityTrackingLocation(ByVal reader As XmlReader, ByVal location As ActivityTrackingLocation)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (location Is Nothing) Then
                Throw New ArgumentNullException("location")
            End If
            If (String.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "ActivityTrackingLocation."))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_01A0:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "ActivityTrackingLocation."))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "TypeName", StringComparison.Ordinal) = 0) Then
                        If (Not location.ActivityType Is Nothing) Then
                            Throw New TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType)
                        End If
                        location.ActivityTypeName = reader.ReadString
                        goto Label_01A0
                    End If
                    If (String.Compare(reader.Name, "Type", StringComparison.Ordinal) = 0) Then
                        If (Not location.ActivityTypeName Is Nothing) Then
                            Throw New TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType)
                        End If
                        If Not reader.IsEmptyElement Then
                            Dim typeName As String = reader.ReadString
                            If ((Not typeName Is Nothing) AndAlso (typeName.Trim.Length > 0)) Then
                                location.ActivityType = Type.GetType(typeName, True)
                            End If
                        End If
                    ElseIf (String.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal) = 0) Then
                        location.MatchDerivedTypes = reader.ReadElementContentAsBoolean
                    ElseIf (String.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal) = 0) Then
                        Me.CreateStatusEvents(reader, location.ExecutionStatusEvents)
                    ElseIf (String.Compare(reader.Name, "Conditions", StringComparison.Ordinal) = 0) Then
                        Me.CreateConditions(reader, location.Conditions)
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal) = 0) Then
                        If ((location.ActivityType Is Nothing) AndAlso (location.ActivityTypeName Is Nothing)) Then
                            location.ActivityType = GetType(Activity)
                            location.MatchDerivedTypes = True
                        End If
                        Return
                    End If
                    goto Label_01A0
            End Select
            goto Label_01A0
        End Sub

        Private Sub CreateActivityTrackingLocations(ByVal reader As XmlReader, ByVal activities As ActivityTrackingLocationCollection)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (activities Is Nothing) Then
                Throw New ArgumentNullException("activities")
            End If
            If Not reader.IsEmptyElement Then
                Dim name As String = reader.Name
                Do While reader.Read
                    Select Case reader.NodeType
                        Case XmlNodeType.Element
                            If (String.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal) = 0) Then
                                Dim location As New ActivityTrackingLocation
                                Me.CreateActivityTrackingLocation(reader, location)
                                activities.Add(location)
                            End If
                            Exit Select
                        Case XmlNodeType.EndElement
                            goto Label_006A
                    End Select
                    [Continue] Do
                Label_006A:
                    If (String.Compare(name, reader.Name, StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                Loop
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & name & "."))
            End If
        End Sub

        Private Sub CreateActivityTrackPoint(ByVal reader As XmlReader, ByVal profile As TrackingProfile)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (profile Is Nothing) Then
                Throw New ArgumentNullException("profile")
            End If
            If (String.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "ActivityTrackPoint."))
            End If
            If Not reader.IsEmptyElement Then
                Dim item As New ActivityTrackPoint
                Do While reader.Read
                    Select Case reader.NodeType
                        Case XmlNodeType.Element
                            If (String.Compare(reader.Name, "Annotations", StringComparison.Ordinal) = 0) Then
                                Me.CreateAnnotations(reader, item.Annotations)
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "MatchingLocations", StringComparison.Ordinal) = 0) Then
                                Me.CreateActivityTrackingLocations(reader, item.MatchingLocations)
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "ExcludedLocations", StringComparison.Ordinal) = 0) Then
                                Me.CreateActivityTrackingLocations(reader, item.ExcludedLocations)
                            ElseIf (String.Compare(reader.Name, "Extracts", StringComparison.Ordinal) = 0) Then
                                Me.CreateExtracts(reader, item.Extracts)
                            End If
                            Exit Select
                        Case XmlNodeType.EndElement
                            goto Label_00FB
                    End Select
                    [Continue] Do
                Label_00FB:
                    If (String.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal) = 0) Then
                        profile.ActivityTrackPoints.Add(item)
                        Return
                    End If
                Loop
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "ActivityTrackPoint."))
            End If
        End Sub

        Private Sub CreateAnnotations(ByVal reader As XmlReader, ByVal annotations As TrackingAnnotationCollection)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (annotations Is Nothing) Then
                Throw New ArgumentNullException("annotations")
            End If
            If (String.Compare(reader.Name, "Annotations", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "Annotations."))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_00A5:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "Annotations."))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "Annotation", StringComparison.Ordinal) = 0) Then
                        If Not reader.IsEmptyElement Then
                            annotations.Add(reader.ReadString)
                        Else
                            annotations.Add(Nothing)
                        End If
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, "Annotations", StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_00A5
            End Select
            goto Label_00A5
        End Sub

        Private Sub CreateCondition(ByVal reader As XmlReader, ByVal condition As TrackingCondition)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (condition Is Nothing) Then
                Throw New ArgumentNullException("condition")
            End If
            If (String.Compare(condition.GetType.Name, reader.Name, StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & condition.GetType.Name))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_015F:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & condition.GetType.Name))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "Member", StringComparison.Ordinal) = 0) Then
                        condition.Member = reader.ReadString
                        goto Label_015F
                    End If
                    If (String.Compare(reader.Name, "Operator", StringComparison.Ordinal) = 0) Then
                        Dim strB As String = reader.ReadString
                        If ((Not strB Is Nothing) AndAlso (strB.Trim.Length > 0)) Then
                            Dim str2 As String
                            For Each str2 In Enum.GetNames(GetType(ComparisonOperator))
                                If (String.Compare(str2, strB, StringComparison.Ordinal) = 0) Then
                                    condition.[Operator] = DirectCast(Enum.Parse(GetType(ComparisonOperator), strB), ComparisonOperator)
                                End If
                            Next
                        End If
                    ElseIf ((String.Compare(reader.Name, "Value", StringComparison.Ordinal) = 0) AndAlso Not reader.IsEmptyElement) Then
                        condition.Value = reader.ReadString
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, condition.GetType.Name, StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_015F
            End Select
            goto Label_015F
        End Sub

        Private Sub CreateConditions(ByVal reader As XmlReader, ByVal conditions As TrackingConditionCollection)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (conditions Is Nothing) Then
                Throw New ArgumentNullException("conditions")
            End If
            If (String.Compare("Conditions", reader.Name, StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "Conditions."))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_009D:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "Conditions."))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "ActivityTrackingCondition", StringComparison.Ordinal) = 0) Then
                        Dim condition As New ActivityTrackingCondition
                        Me.CreateCondition(reader, condition)
                        conditions.Add(condition)
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, "Conditions", StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_009D
            End Select
            goto Label_009D
        End Sub

        Private Sub CreateExtract(ByVal reader As XmlReader, ByVal extract As TrackingExtract)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (extract Is Nothing) Then
                Throw New ArgumentNullException("extract")
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_0094:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & extract.GetType.Name))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "Member", StringComparison.Ordinal) = 0) Then
                        extract.Member = reader.ReadString
                    ElseIf (String.Compare(reader.Name, "Annotations", StringComparison.Ordinal) = 0) Then
                        Me.CreateAnnotations(reader, extract.Annotations)
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, extract.GetType.Name, StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_0094
            End Select
            goto Label_0094
        End Sub

        Private Sub CreateExtracts(ByVal reader As XmlReader, ByVal extracts As ExtractCollection)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (extracts Is Nothing) Then
                Throw New ArgumentNullException("extracts")
            End If
            If (String.Compare("Extracts", reader.Name, StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "Extracts"))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_00C7:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "Extracts."))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "ActivityDataTrackingExtract", StringComparison.Ordinal) = 0) Then
                        Dim extract As New ActivityDataTrackingExtract
                        Me.CreateExtract(reader, extract)
                        extracts.Add(extract)
                    ElseIf (String.Compare(reader.Name, "WorkflowDataTrackingExtract", StringComparison.Ordinal) = 0) Then
                        Dim extract2 As New WorkflowDataTrackingExtract
                        Me.CreateExtract(reader, extract2)
                        extracts.Add(extract2)
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, "Extracts", StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_00C7
            End Select
            goto Label_00C7
        End Sub

        Private Sub CreateStatusEvents(ByVal reader As XmlReader, ByVal events As IList([Of] ActivityExecutionStatus))
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (events Is Nothing) Then
                Throw New ArgumentNullException("events")
            End If
            If (String.Compare("ExecutionStatusEvents", reader.Name, StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "ExecutionStatusEvents."))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_00FA:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "ExecutionStatusEvents."))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "ExecutionStatus", StringComparison.Ordinal) = 0) Then
                        Dim strB As String = reader.ReadString
                        If ((Not strB Is Nothing) AndAlso (strB.Trim.Length > 0)) Then
                            Dim str2 As String
                            For Each str2 In Enum.GetNames(GetType(ActivityExecutionStatus))
                                If (String.Compare(str2, strB, StringComparison.Ordinal) = 0) Then
                                    events.Add(DirectCast(Enum.Parse(GetType(ActivityExecutionStatus), strB), ActivityExecutionStatus))
                                End If
                            Next
                        End If
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_00FA
            End Select
            goto Label_00FA
        End Sub

        Private Sub CreateTrackPoints(ByVal reader As XmlReader, ByVal profile As TrackingProfile)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (profile Is Nothing) Then
                Throw New ArgumentNullException("profile")
            End If
            If (String.Compare(reader.Name, "TrackPoints", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "TrackPoints."))
            End If
            If reader.IsEmptyElement Then
                Return
            End If
        Label_00CA:
            If Not reader.Read Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "TrackPoints."))
            End If
            Select Case reader.NodeType
                Case XmlNodeType.Element
                    If (String.Compare(reader.Name, "ActivityTrackPoint", StringComparison.Ordinal) = 0) Then
                        Me.CreateActivityTrackPoint(reader, profile)
                        goto Label_00CA
                    End If
                    If (String.Compare(reader.Name, "UserTrackPoint", StringComparison.Ordinal) = 0) Then
                        Me.CreateUserTrackPoint(reader, profile)
                    ElseIf (String.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal) = 0) Then
                        Me.CreateWorkflowTrackPoint(reader, profile)
                    End If
                    Exit Select
                Case XmlNodeType.EndElement
                    If (String.Compare(reader.Name, "TrackPoints", StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                    goto Label_00CA
            End Select
            goto Label_00CA
        End Sub

        Private Sub CreateUserTrackingLocation(ByVal reader As XmlReader, ByVal location As UserTrackingLocation)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (location Is Nothing) Then
                Throw New ArgumentNullException("location")
            End If
            If (String.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "UserTrackingLocation."))
            End If
            If Not reader.IsEmptyElement Then
                Dim str As String = Nothing
                Dim typeName As String = Nothing
                Dim flag As Boolean = False
                Dim flag2 As Boolean = False
                Dim flag3 As Boolean = False
                Do While reader.Read
                    Select Case reader.NodeType
                        Case XmlNodeType.Element
                            If (String.Compare(reader.Name, "Activity", StringComparison.Ordinal) = 0) Then
                                flag2 = True
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "KeyName", StringComparison.Ordinal) = 0) Then
                                location.KeyName = reader.ReadString
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "Argument", StringComparison.Ordinal) = 0) Then
                                flag3 = True
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "TypeName", StringComparison.Ordinal) = 0) Then
                                str = reader.ReadString
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "Type", StringComparison.Ordinal) = 0) Then
                                typeName = reader.ReadString
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal) = 0) Then
                                flag = reader.ReadElementContentAsBoolean
                            ElseIf (String.Compare(reader.Name, "Conditions", StringComparison.Ordinal) = 0) Then
                                Me.CreateConditions(reader, location.Conditions)
                            End If
                            Exit Select
                        Case XmlNodeType.EndElement
                            If (String.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal) <> 0) Then
                                goto Label_01F1
                            End If
                            If Not flag2 Then
                                location.ActivityType = GetType(Activity)
                                location.MatchDerivedActivityTypes = True
                            End If
                            If Not flag3 Then
                                location.ArgumentType = GetType(Object)
                                location.MatchDerivedArgumentTypes = True
                            End If
                            If (((location.ActivityType Is Nothing) AndAlso ((location.ActivityTypeName Is Nothing) OrElse (location.ActivityTypeName.Trim.Length = 0))) AndAlso ((location.ArgumentType Is Nothing) AndAlso ((location.ArgumentTypeName Is Nothing) OrElse (location.ArgumentTypeName.Trim.Length = 0)))) Then
                                Throw New TrackingProfileDeserializationException(ExecutionStringManager.MissingActivityType)
                            End If
                            Return
                    End Select
                    [Continue] Do
                Label_01F1:
                    If (String.Compare(reader.Name, "Activity", StringComparison.Ordinal) = 0) Then
                        If Not flag2 Then
                            location.ActivityType = GetType(Activity)
                            location.MatchDerivedActivityTypes = True
                        Else
                            If ((Not typeName Is Nothing) AndAlso (typeName.Trim.Length > 0)) Then
                                location.ActivityType = Type.GetType(typeName, True)
                            Else
                                location.ActivityTypeName = str
                            End If
                            location.MatchDerivedActivityTypes = flag
                        End If
                        str = Nothing
                        typeName = Nothing
                        flag = False
                    ElseIf (String.Compare(reader.Name, "Argument", StringComparison.Ordinal) = 0) Then
                        If Not flag3 Then
                            location.ArgumentType = GetType(Object)
                            location.MatchDerivedArgumentTypes = True
                        Else
                            If ((Not typeName Is Nothing) AndAlso (typeName.Trim.Length > 0)) Then
                                location.ArgumentType = Type.GetType(typeName, True)
                            Else
                                location.ArgumentTypeName = str
                            End If
                            location.MatchDerivedArgumentTypes = flag
                        End If
                        str = Nothing
                        typeName = Nothing
                        flag = False
                    End If
                Loop
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "UserTrackingLocation."))
            End If
        End Sub

        Private Sub CreateUserTrackingLocations(ByVal reader As XmlReader, ByVal user As UserTrackingLocationCollection)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (user Is Nothing) Then
                Throw New ArgumentNullException("user")
            End If
            If Not reader.IsEmptyElement Then
                Dim name As String = reader.Name
                Do While reader.Read
                    Select Case reader.NodeType
                        Case XmlNodeType.Element
                            If (String.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal) = 0) Then
                                Dim location As New UserTrackingLocation
                                Me.CreateUserTrackingLocation(reader, location)
                                user.Add(location)
                            End If
                            Exit Select
                        Case XmlNodeType.EndElement
                            goto Label_006A
                    End Select
                    [Continue] Do
                Label_006A:
                    If (String.Compare(name, reader.Name, StringComparison.Ordinal) = 0) Then
                        Return
                    End If
                Loop
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & name & "."))
            End If
        End Sub

        Private Sub CreateUserTrackPoint(ByVal reader As XmlReader, ByVal profile As TrackingProfile)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (profile Is Nothing) Then
                Throw New ArgumentNullException("profile")
            End If
            If (String.Compare(reader.Name, "UserTrackPoint", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "UserTrackPoint."))
            End If
            If Not reader.IsEmptyElement Then
                Dim item As New UserTrackPoint
                Do While reader.Read
                    Select Case reader.NodeType
                        Case XmlNodeType.Element
                            If (String.Compare(reader.Name, "Annotations", StringComparison.Ordinal) = 0) Then
                                Me.CreateAnnotations(reader, item.Annotations)
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "MatchingLocations", StringComparison.Ordinal) = 0) Then
                                Me.CreateUserTrackingLocations(reader, item.MatchingLocations)
                                [Continue]
                            End If
                            If (String.Compare(reader.Name, "ExcludedLocations", StringComparison.Ordinal) = 0) Then
                                Me.CreateUserTrackingLocations(reader, item.ExcludedLocations)
                            ElseIf (String.Compare(reader.Name, "Extracts", StringComparison.Ordinal) = 0) Then
                                Me.CreateExtracts(reader, item.Extracts)
                            End If
                            Exit Select
                        Case XmlNodeType.EndElement
                            goto Label_00FB
                    End Select
                    [Continue] Do
                Label_00FB:
                    If (String.Compare(reader.Name, "UserTrackPoint", StringComparison.Ordinal) = 0) Then
                        profile.UserTrackPoints.Add(item)
                        Return
                    End If
                Loop
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "UserTrackPoint."))
            End If
        End Sub

        Private Sub CreateWorkflowTrackPoint(ByVal reader As XmlReader, ByVal profile As TrackingProfile)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            If (profile Is Nothing) Then
                Throw New ArgumentNullException("profile")
            End If
            If (String.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal) <> 0) Then
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationInvalidPosition & "WorkflowTrackPoint."))
            End If
            If Not reader.IsEmptyElement Then
                Dim item As New WorkflowTrackPoint { _
                    .MatchingLocation = New WorkflowTrackingLocation _
                }
                Do While reader.Read
                    Select Case reader.NodeType
                        Case XmlNodeType.Element
                            If (String.Compare(reader.Name, "Annotations", StringComparison.Ordinal) = 0) Then
                                Me.CreateAnnotations(reader, item.Annotations)
                            ElseIf (String.Compare(reader.Name, "TrackingWorkflowEvent", StringComparison.Ordinal) = 0) Then
                                item.MatchingLocation.Events.Add(DirectCast(Enum.Parse(GetType(TrackingWorkflowEvent), reader.ReadString), TrackingWorkflowEvent))
                            End If
                            Exit Select
                        Case XmlNodeType.EndElement
                            goto Label_00D9
                    End Select
                    [Continue] Do
                Label_00D9:
                    If (String.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal) = 0) Then
                        profile.WorkflowTrackPoints.Add(item)
                        Return
                    End If
                Loop
                Throw New TrackingProfileDeserializationException((ExecutionStringManager.TrackingDeserializationCloseElementNotFound & "WorkflowTrackPoint."))
            End If
        End Sub

        Public Function Deserialize(ByVal reader As TextReader) As TrackingProfile
            Dim profile As TrackingProfile = Nothing
            Me._vArgs = New List([Of] ValidationEventArgs)
            Me._vex = False
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
            Dim nameTable As New NameTable
            Dim nsMgr As New XmlNamespaceManager(nameTable)
            nsMgr.AddNamespace(String.Empty, "http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile")
            Dim inputContext As New XmlParserContext(nameTable, nsMgr, Nothing, XmlSpace.None)
            Dim reader2 As XmlReader = XmlReader.Create(reader, Me.GetSchemaReaderSettings, inputContext)
            Try 
                profile = New TrackingProfile
                If Not reader2.ReadToDescendant("TrackingProfile") Then
                    Me.CheckSchemaErrors
                    Return Nothing
                End If
                Dim attribute As String = reader2.GetAttribute("version")
                If ((attribute Is Nothing) OrElse (attribute.Trim.Length = 0)) Then
                    Throw New TrackingProfileDeserializationException(ExecutionStringManager.InvalidProfileVersion)
                End If
                profile.Version = New Version(attribute)
                If Not reader2.ReadToDescendant("TrackPoints") Then
                    Me.CheckSchemaErrors
                    Return Nothing
                End If
                Me.CreateTrackPoints(reader2, profile)
                Me.CheckSchemaErrors
            Catch exception1 As Exception
                profile = Nothing
                Throw
            Finally
                Me._vArgs = New List([Of] ValidationEventArgs)
                Me._vex = False
                reader2.Close
            End Try
            Return profile
        End Function

        Private Function GetSchemaReaderSettings() As XmlReaderSettings
            Dim settings As New XmlReaderSettings
            settings.Schemas.Add(Me._schema)
            settings.ValidationType = ValidationType.Schema
            settings.ConformanceLevel = ConformanceLevel.Document
            settings.CloseInput = False
            settings.IgnoreComments = True
            settings.IgnoreProcessingInstructions = True
            settings.ProhibitDtd = True
            AddHandler settings.ValidationEventHandler, New ValidationEventHandler(AddressOf Me.ValidationCallBack)
            Return settings
        End Function

        Private Sub InitWriter(ByVal writer As XmlTextWriter)
            writer.Formatting = Formatting.Indented
            writer.Indentation = 4
        End Sub

        Private Function IsStatus(ByVal val As Integer) As Boolean
            Dim status As ActivityExecutionStatus
            For Each status In Enum.GetValues(GetType(ActivityExecutionStatus))
                If (CInt(status) = val) Then
                    Return True
                End If
            Next
            Return False
        End Function

        Private Function IsWorkflowEvent(ByVal val As Integer) As Boolean
            Dim event2 As TrackingWorkflowEvent
            For Each event2 In Enum.GetValues(GetType(TrackingWorkflowEvent))
                If (event2 = val) Then
                    Return True
                End If
            Next
            Return False
        End Function

        Public Sub Serialize(ByVal writer As TextWriter, ByVal profile As TrackingProfile)
            If (profile Is Nothing) Then
                Throw New ArgumentNullException("profile")
            End If
            If (writer Is Nothing) Then
                Throw New ArgumentNullException("writer")
            End If
            Dim writer2 As New XmlTextWriter(writer)
            Me.InitWriter(writer2)
            Me.Write(profile, writer2)
            writer2.Flush
            writer2.Close
        End Sub

        Private Sub ValidationCallBack(ByVal sender As Object, ByVal e As ValidationEventArgs)
            Me._vArgs.Add(e)
            If (e.Severity = XmlSeverityType.Error) Then
                Me._vex = True
            End If
        End Sub

        Private Sub Write(ByVal profile As TrackingProfile, ByVal writer As XmlTextWriter)
            writer.WriteStartDocument(True)
            writer.WriteStartElement("TrackingProfile")
            writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile")
            If (Nothing Is profile.Version) Then
                Throw New ArgumentException(ExecutionStringManager.InvalidProfileVersion)
            End If
            Dim str As String = Nothing
            If (profile.Version.Revision >= 0) Then
                str = String.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}.{2}.{3}", New Object() { profile.Version.Major, profile.Version.Minor, profile.Version.Build, profile.Version.Revision })
            ElseIf (profile.Version.Build >= 0) Then
                str = String.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}.{2}", New Object() { profile.Version.Major, profile.Version.Minor, profile.Version.Build })
            ElseIf (profile.Version.Minor >= 0) Then
                str = String.Format(NumberFormatInfo.InvariantInfo, "{0}.{1}", New Object() { profile.Version.Major, profile.Version.Minor })
            End If
            writer.WriteAttributeString("version", str)
            Me.WriteTrackPoints(profile, writer)
            writer.WriteEndElement
            writer.WriteEndDocument
        End Sub

        Private Sub WriteActivityTrackingLocation(ByVal loc As ActivityTrackingLocation, ByVal writer As XmlTextWriter)
            If ((loc.ActivityType Is Nothing) AndAlso ((loc.ActivityTypeName Is Nothing) OrElse (loc.ActivityTypeName.Trim.Length = 0))) Then
                Throw New ArgumentException(ExecutionStringManager.MissingActivityType)
            End If
            writer.WriteStartElement("ActivityTrackingLocation")
            writer.WriteStartElement("Activity")
            If (Not loc.ActivityType Is Nothing) Then
                writer.WriteElementString("Type", loc.ActivityType.AssemblyQualifiedName)
            Else
                writer.WriteElementString("TypeName", loc.ActivityTypeName)
            End If
            writer.WriteElementString("MatchDerivedTypes", loc.MatchDerivedTypes.ToString.ToLower(CultureInfo.InvariantCulture))
            writer.WriteEndElement
            Me.WriteEvents(loc.ExecutionStatusEvents, writer)
            If ((Not loc.Conditions Is Nothing) AndAlso (loc.Conditions.Count > 0)) Then
                Me.WriteConditions(loc.Conditions, writer)
            End If
            writer.WriteEndElement
        End Sub

        Private Sub WriteActivityTrackPoint(ByVal point As ActivityTrackPoint, ByVal writer As XmlTextWriter)
            If (point Is Nothing) Then
                Throw New ArgumentNullException("point")
            End If
            If ((point.MatchingLocations Is Nothing) OrElse (point.MatchingLocations.Count = 0)) Then
                Throw New ArgumentException(ExecutionStringManager.NoMatchingLocations)
            End If
            writer.WriteStartElement("ActivityTrackPoint")
            writer.WriteStartElement("MatchingLocations")
            Dim num As Integer = 0
            Dim location As ActivityTrackingLocation
            For Each location In point.MatchingLocations
                If (Not location Is Nothing) Then
                    Me.WriteActivityTrackingLocation(location, writer)
                    num += 1
                End If
            Next
            If (num = 0) Then
                Throw New ArgumentException(ExecutionStringManager.NoMatchingLocations)
            End If
            writer.WriteEndElement
            If ((Not point.ExcludedLocations Is Nothing) AndAlso (point.ExcludedLocations.Count > 0)) Then
                writer.WriteStartElement("ExcludedLocations")
                Dim location2 As ActivityTrackingLocation
                For Each location2 In point.ExcludedLocations
                    If (Not location2 Is Nothing) Then
                        Me.WriteActivityTrackingLocation(location2, writer)
                    End If
                Next
                writer.WriteEndElement
            End If
            Me.WriteAnnotations(point.Annotations, writer)
            Me.WriteExtracts(point.Extracts, writer)
            writer.WriteEndElement
        End Sub

        Private Sub WriteAnnotations(ByVal annotations As TrackingAnnotationCollection, ByVal writer As XmlTextWriter)
            If ((Not annotations Is Nothing) AndAlso (annotations.Count <> 0)) Then
                writer.WriteStartElement("Annotations")
                Dim str As String
                For Each str In annotations
                    writer.WriteStartElement("Annotation")
                    If ((str Is Nothing) OrElse (str.Length > 0)) Then
                        writer.WriteValue(If((str Is Nothing), String.Empty, str))
                        writer.WriteEndElement
                    Else
                        writer.WriteFullEndElement
                    End If
                Next
                writer.WriteEndElement
            End If
        End Sub

        Private Sub WriteCondition(ByVal condition As TrackingCondition, ByVal writer As XmlTextWriter)
            If (Not condition Is Nothing) Then
                writer.WriteStartElement(condition.GetType.Name)
                writer.WriteElementString("Operator", condition.[Operator].ToString)
                If ((condition.Member Is Nothing) OrElse (condition.Member.Trim.Length = 0)) Then
                    Throw New ArgumentException(ExecutionStringManager.MissingMemberName)
                End If
                writer.WriteElementString("Member", condition.Member)
                If (Not condition.Value Is Nothing) Then
                    If (String.Empty = condition.Value) Then
                        writer.WriteStartElement("Value")
                        writer.WriteRaw(String.Empty)
                        writer.WriteEndElement
                    Else
                        writer.WriteElementString("Value", condition.Value)
                    End If
                End If
                writer.WriteEndElement
            End If
        End Sub

        Private Sub WriteConditions(ByVal conditions As TrackingConditionCollection, ByVal writer As XmlTextWriter)
            If ((Not conditions Is Nothing) AndAlso (conditions.Count <> 0)) Then
                writer.WriteStartElement("Conditions")
                Dim condition As TrackingCondition
                For Each condition In conditions
                    If (Not condition Is Nothing) Then
                        Me.WriteCondition(condition, writer)
                    End If
                Next
                writer.WriteEndElement
            End If
        End Sub

        Private Sub WriteEvents(ByVal events As IList([Of] ActivityExecutionStatus), ByVal writer As XmlTextWriter)
            If ((events Is Nothing) OrElse (events.Count = 0)) Then
                Throw New ArgumentException(ExecutionStringManager.MissingActivityEvents)
            End If
            writer.WriteStartElement("ExecutionStatusEvents")
            Dim status As ActivityExecutionStatus
            For Each status In events
                If Not Me.IsStatus(CInt(status)) Then
                    Throw New ArgumentException(ExecutionStringManager.InvalidStatus)
                End If
                writer.WriteStartElement("ExecutionStatus")
                writer.WriteValue(status.ToString)
                writer.WriteEndElement
            Next
            writer.WriteEndElement
        End Sub

        Private Sub WriteExtract(ByVal extract As TrackingExtract, ByVal writer As XmlTextWriter)
            extract.GetType
            If (Not TypeOf extract Is ActivityDataTrackingExtract AndAlso Not TypeOf extract Is WorkflowDataTrackingExtract) Then
                Throw New ArgumentException(ExecutionStringManager.TrackingSerializationInvalidExtract)
            End If
            writer.WriteStartElement(extract.GetType.Name)
            writer.WriteElementString("Member", If((extract.Member Is Nothing), String.Empty, extract.Member))
            Me.WriteAnnotations(extract.Annotations, writer)
            writer.WriteEndElement
        End Sub

        Private Sub WriteExtracts(ByVal extracts As ExtractCollection, ByVal writer As XmlTextWriter)
            If ((Not extracts Is Nothing) AndAlso (extracts.Count <> 0)) Then
                writer.WriteStartElement("Extracts")
                Dim extract As TrackingExtract
                For Each extract In extracts
                    If (Not extract Is Nothing) Then
                        Me.WriteExtract(extract, writer)
                    End If
                Next
                writer.WriteEndElement
            End If
        End Sub

        Private Sub WriteTrackPoints(ByVal profile As TrackingProfile, ByVal writer As XmlTextWriter)
            If ((((profile.WorkflowTrackPoints Is Nothing) OrElse (profile.WorkflowTrackPoints.Count = 0)) AndAlso ((profile.ActivityTrackPoints Is Nothing) OrElse (profile.ActivityTrackPoints.Count = 0))) AndAlso ((profile.UserTrackPoints Is Nothing) OrElse (profile.UserTrackPoints.Count = 0))) Then
                Throw New ArgumentException(ExecutionStringManager.TrackingSerializationNoTrackPoints)
            End If
            Dim num As Integer = 0
            writer.WriteStartElement("TrackPoints")
            Dim point As WorkflowTrackPoint
            For Each point In profile.WorkflowTrackPoints
                If (Not point Is Nothing) Then
                    Me.WriteWorkflowTrackPoint(point, writer)
                    num += 1
                End If
            Next
            Dim point2 As ActivityTrackPoint
            For Each point2 In profile.ActivityTrackPoints
                If (Not point2 Is Nothing) Then
                    Me.WriteActivityTrackPoint(point2, writer)
                    num += 1
                End If
            Next
            Dim point3 As UserTrackPoint
            For Each point3 In profile.UserTrackPoints
                If (Not point3 Is Nothing) Then
                    Me.WriteUserTrackPoint(point3, writer)
                    num += 1
                End If
            Next
            If (num = 0) Then
                Throw New ArgumentException(ExecutionStringManager.TrackingSerializationNoTrackPoints)
            End If
            writer.WriteEndElement
        End Sub

        Private Sub WriteUserTrackingLocation(ByVal loc As UserTrackingLocation, ByVal writer As XmlTextWriter)
            If ((loc.ActivityType Is Nothing) AndAlso ((loc.ActivityTypeName Is Nothing) OrElse (loc.ActivityTypeName.Trim.Length = 0))) Then
                Throw New ArgumentException(ExecutionStringManager.MissingActivityType)
            End If
            If ((loc.ArgumentType Is Nothing) AndAlso ((loc.ArgumentTypeName Is Nothing) OrElse (loc.ArgumentTypeName.Trim.Length = 0))) Then
                Throw New ArgumentException(ExecutionStringManager.MissingArgumentType)
            End If
            writer.WriteStartElement("UserTrackingLocation")
            writer.WriteStartElement("Activity")
            If (Not loc.ActivityType Is Nothing) Then
                writer.WriteElementString("Type", loc.ActivityType.AssemblyQualifiedName)
            Else
                writer.WriteElementString("TypeName", loc.ActivityTypeName)
            End If
            writer.WriteElementString("MatchDerivedTypes", loc.MatchDerivedActivityTypes.ToString.ToLower(CultureInfo.InvariantCulture))
            writer.WriteEndElement
            If (Not loc.KeyName Is Nothing) Then
                writer.WriteElementString("KeyName", loc.KeyName)
            End If
            writer.WriteStartElement("Argument")
            If (Not loc.ArgumentType Is Nothing) Then
                writer.WriteElementString("Type", loc.ArgumentType.AssemblyQualifiedName)
            Else
                writer.WriteElementString("TypeName", loc.ArgumentTypeName)
            End If
            writer.WriteElementString("MatchDerivedTypes", loc.MatchDerivedArgumentTypes.ToString.ToLower(CultureInfo.InvariantCulture))
            writer.WriteEndElement
            If ((Not loc.Conditions Is Nothing) AndAlso (loc.Conditions.Count > 0)) Then
                Me.WriteConditions(loc.Conditions, writer)
            End If
            writer.WriteEndElement
        End Sub

        Private Sub WriteUserTrackPoint(ByVal point As UserTrackPoint, ByVal writer As XmlTextWriter)
            If ((point.MatchingLocations Is Nothing) OrElse (point.MatchingLocations.Count = 0)) Then
                Throw New ArgumentException(ExecutionStringManager.NoMatchingLocations)
            End If
            writer.WriteStartElement("UserTrackPoint")
            writer.WriteStartElement("MatchingLocations")
            Dim num As Integer = 0
            Dim location As UserTrackingLocation
            For Each location In point.MatchingLocations
                If (Not location Is Nothing) Then
                    Me.WriteUserTrackingLocation(location, writer)
                    num += 1
                End If
            Next
            If (num = 0) Then
                Throw New ArgumentException(ExecutionStringManager.NoMatchingLocations)
            End If
            writer.WriteEndElement
            If ((Not point.ExcludedLocations Is Nothing) AndAlso (point.ExcludedLocations.Count > 0)) Then
                writer.WriteStartElement("ExcludedLocations")
                Dim location2 As UserTrackingLocation
                For Each location2 In point.ExcludedLocations
                    If (Not location2 Is Nothing) Then
                        Me.WriteUserTrackingLocation(location2, writer)
                    End If
                Next
                writer.WriteEndElement
            End If
            Me.WriteAnnotations(point.Annotations, writer)
            Me.WriteExtracts(point.Extracts, writer)
            writer.WriteEndElement
        End Sub

        Private Sub WriteWorkflowEvents(ByVal events As IList([Of] TrackingWorkflowEvent), ByVal writer As XmlTextWriter)
            If ((Not events Is Nothing) AndAlso (events.Count <> 0)) Then
                writer.WriteStartElement("TrackingWorkflowEvents")
                Dim event2 As TrackingWorkflowEvent
                For Each event2 In events
                    If Not Me.IsWorkflowEvent(CInt(event2)) Then
                        Throw New ArgumentException(ExecutionStringManager.InvalidWorkflowEvent)
                    End If
                    writer.WriteStartElement("TrackingWorkflowEvent")
                    writer.WriteValue(event2.ToString)
                    writer.WriteEndElement
                Next
                writer.WriteEndElement
            End If
        End Sub

        Private Sub WriteWorkflowTrackingLocation(ByVal loc As WorkflowTrackingLocation, ByVal writer As XmlTextWriter)
            If ((loc.Events Is Nothing) OrElse (loc.Events.Count = 0)) Then
                Throw New ArgumentException(ExecutionStringManager.MissingWorkflowEvents)
            End If
            writer.WriteStartElement("MatchingLocation")
            writer.WriteStartElement("WorkflowTrackingLocation")
            Me.WriteWorkflowEvents(loc.Events, writer)
            writer.WriteEndElement
            writer.WriteEndElement
        End Sub

        Private Sub WriteWorkflowTrackPoint(ByVal point As WorkflowTrackPoint, ByVal writer As XmlTextWriter)
            If (point.MatchingLocation Is Nothing) Then
                Throw New ArgumentException(ExecutionStringManager.NoMatchingLocation)
            End If
            writer.WriteStartElement("WorkflowTrackPoint")
            Me.WriteWorkflowTrackingLocation(point.MatchingLocation, writer)
            Me.WriteAnnotations(point.Annotations, writer)
            writer.WriteEndElement
        End Sub


        ' Properties
        Public ReadOnly Property Schema As XmlSchema
            Get
                Return Me._schema
            End Get
        End Property


        ' Fields
        Private Const _ns As String = "http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"
        Private _schema As XmlSchema = XmlSchema.Read(New StringReader("<?xml version=""1.0"" encoding=""utf-8""?>" & ChrW(13) & ChrW(10) & "<xs:schema id=""WFTrackingProfile"" targetNamespace=""http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"" elementFormDefault=""qualified"" xmlns=""http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">" & ChrW(13) & ChrW(10) & "    <xs:element name=""TrackingProfile"" type=""TrackingProfileType"" />" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""TrackingProfileType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""TrackPoints"" type=""TrackPointListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "        <xs:attribute name=""version"" type=""VersionType"" />" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""TrackPointListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:choice minOccurs=""1"" maxOccurs=""unbounded"">" & ChrW(13) & ChrW(10) & "                <xs:element name=""ActivityTrackPoint"" type=""ActivityTrackPointType"" />" & ChrW(13) & ChrW(10) & "                <xs:element name=""UserTrackPoint"" type=""UserTrackPointType"" />" & ChrW(13) & ChrW(10) & "                <xs:element name=""WorkflowTrackPoint"" type=""WorkflowTrackPointType""  />" & ChrW(13) & ChrW(10) & "            </xs:choice>" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityTrackPointType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchingLocations"" minOccurs=""1"" maxOccurs=""1"" type=""IncludeActivityTrackingLocationListType"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExcludedLocations"" minOccurs=""0"" maxOccurs=""1"" type=""ExcludeActivityTrackingLocationListType"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Extracts"" type=""ExtractListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""IncludeActivityTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityTrackingLocation"" type=""ActivityTrackingLocationType"" minOccurs=""1"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExcludeActivityTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityTrackingLocation"" type=""ActivityTrackingLocationType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityTrackingLocationType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""Activity"" type=""Type"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExecutionStatusEvents"" type=""ExecutionStatusEventListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Conditions"" type=""ConditionListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""UserTrackPointType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchingLocations"" type=""IncludeUserTrackingLocationListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExcludedLocations"" type=""ExcludeUserTrackingLocationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Extracts"" type=""ExtractListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""IncludeUserTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""UserTrackingLocation"" type=""UserTrackingLocationType"" minOccurs=""1"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExcludeUserTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""UserTrackingLocation"" type=""UserTrackingLocationType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""UserTrackingLocationType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""Activity"" type=""Type"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""KeyName"" type=""NonNullString"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Argument"" type=""Type"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Conditions"" type=""ConditionListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowTrackPointType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchingLocation"" type=""WorkflowTrackingLocationMatchType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowTrackingLocationMatchType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""WorkflowTrackingLocation"" type=""WorkflowTrackingLocationType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowTrackingLocationType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""TrackingWorkflowEvents"" type=""TrackingWorkflowEventListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""Type"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:choice>" & ChrW(13) & ChrW(10) & "                <xs:element name=""TypeName"" type=""NonNullString"" />" & ChrW(13) & ChrW(10) & "                <xs:element name=""Type"" type=""NonNullString"" />" & ChrW(13) & ChrW(10) & "            </xs:choice>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchDerivedTypes"" type=""xs:boolean"" minOccurs=""1"" maxOccurs=""1"" default=""false"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""AnnotationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotation"" type=""xs:string"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ConditionListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityTrackingCondition"" type=""ActivityTrackingConditionType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityTrackingConditionType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence minOccurs=""1"" maxOccurs=""1"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""Operator"" type=""OperatorType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Member"" type=""NonNullString"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Value"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1"" nillable=""true"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""OperatorType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Equals"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""NotEquals"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExecutionStatusEventListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExecutionStatus"" type=""ExecutionStatusType"" minOccurs=""1"" maxOccurs=""6"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""ExecutionStatusType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Initialized"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Executing"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Compensating"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Canceling"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Closed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Faulting"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""TrackingWorkflowEventListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""TrackingWorkflowEvent"" type=""TrackingWorkflowEventType"" minOccurs=""1"" maxOccurs=""13"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & "        " & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""TrackingWorkflowEventType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Created"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Completed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Idle"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Suspended"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Resumed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Persisted"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Unloaded"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Loaded"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Exception"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Terminated"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Aborted"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Changed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Started"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExtractListType"">" & ChrW(13) & ChrW(10) & "        <xs:choice minOccurs=""0"" maxOccurs=""unbounded"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityDataTrackingExtract"" type=""ActivityDataTrackingExtractType"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""WorkflowDataTrackingExtract"" type=""WorkflowDataTrackingExtractType"" />" & ChrW(13) & ChrW(10) & "        </xs:choice>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityDataTrackingExtractType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence minOccurs=""1"" maxOccurs=""1"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""Member"" type=""xs:string"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowDataTrackingExtractType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence minOccurs=""1"" maxOccurs=""1"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""Member"" type=""xs:string"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""VersionType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:pattern value=""(^(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))$)|(^(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))$)|(^(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))$)"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""NonNullString"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:minLength value=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & "</xs:schema>"), Nothing)
        Private _vArgs As List([Of] ValidationEventArgs) = New List([Of] ValidationEventArgs)
        Private _vex As Boolean
        Friend Const _xsd As String = "<?xml version=""1.0"" encoding=""utf-8""?>" & ChrW(13) & ChrW(10) & "<xs:schema id=""WFTrackingProfile"" targetNamespace=""http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"" elementFormDefault=""qualified"" xmlns=""http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">" & ChrW(13) & ChrW(10) & "    <xs:element name=""TrackingProfile"" type=""TrackingProfileType"" />" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""TrackingProfileType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""TrackPoints"" type=""TrackPointListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "        <xs:attribute name=""version"" type=""VersionType"" />" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""TrackPointListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:choice minOccurs=""1"" maxOccurs=""unbounded"">" & ChrW(13) & ChrW(10) & "                <xs:element name=""ActivityTrackPoint"" type=""ActivityTrackPointType"" />" & ChrW(13) & ChrW(10) & "                <xs:element name=""UserTrackPoint"" type=""UserTrackPointType"" />" & ChrW(13) & ChrW(10) & "                <xs:element name=""WorkflowTrackPoint"" type=""WorkflowTrackPointType""  />" & ChrW(13) & ChrW(10) & "            </xs:choice>" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityTrackPointType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchingLocations"" minOccurs=""1"" maxOccurs=""1"" type=""IncludeActivityTrackingLocationListType"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExcludedLocations"" minOccurs=""0"" maxOccurs=""1"" type=""ExcludeActivityTrackingLocationListType"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Extracts"" type=""ExtractListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""IncludeActivityTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityTrackingLocation"" type=""ActivityTrackingLocationType"" minOccurs=""1"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExcludeActivityTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityTrackingLocation"" type=""ActivityTrackingLocationType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityTrackingLocationType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""Activity"" type=""Type"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExecutionStatusEvents"" type=""ExecutionStatusEventListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Conditions"" type=""ConditionListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""UserTrackPointType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchingLocations"" type=""IncludeUserTrackingLocationListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExcludedLocations"" type=""ExcludeUserTrackingLocationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Extracts"" type=""ExtractListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""IncludeUserTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""UserTrackingLocation"" type=""UserTrackingLocationType"" minOccurs=""1"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExcludeUserTrackingLocationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""UserTrackingLocation"" type=""UserTrackingLocationType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""UserTrackingLocationType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""Activity"" type=""Type"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""KeyName"" type=""NonNullString"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Argument"" type=""Type"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Conditions"" type=""ConditionListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowTrackPointType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchingLocation"" type=""WorkflowTrackingLocationMatchType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowTrackingLocationMatchType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""WorkflowTrackingLocation"" type=""WorkflowTrackingLocationType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowTrackingLocationType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""TrackingWorkflowEvents"" type=""TrackingWorkflowEventListType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""Type"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:choice>" & ChrW(13) & ChrW(10) & "                <xs:element name=""TypeName"" type=""NonNullString"" />" & ChrW(13) & ChrW(10) & "                <xs:element name=""Type"" type=""NonNullString"" />" & ChrW(13) & ChrW(10) & "            </xs:choice>" & ChrW(13) & ChrW(10) & "            <xs:element name=""MatchDerivedTypes"" type=""xs:boolean"" minOccurs=""1"" maxOccurs=""1"" default=""false"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""AnnotationListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotation"" type=""xs:string"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ConditionListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityTrackingCondition"" type=""ActivityTrackingConditionType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityTrackingConditionType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence minOccurs=""1"" maxOccurs=""1"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""Operator"" type=""OperatorType"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Member"" type=""NonNullString"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Value"" type=""xs:string"" minOccurs=""0"" maxOccurs=""1"" nillable=""true"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""OperatorType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Equals"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""NotEquals"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExecutionStatusEventListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""ExecutionStatus"" type=""ExecutionStatusType"" minOccurs=""1"" maxOccurs=""6"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""ExecutionStatusType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Initialized"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Executing"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Compensating"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Canceling"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Closed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Faulting"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""TrackingWorkflowEventListType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence>" & ChrW(13) & ChrW(10) & "            <xs:element name=""TrackingWorkflowEvent"" type=""TrackingWorkflowEventType"" minOccurs=""1"" maxOccurs=""13"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & "        " & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""TrackingWorkflowEventType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Created"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Completed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Idle"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Suspended"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Resumed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Persisted"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Unloaded"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Loaded"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Exception"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Terminated"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Aborted"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Changed"" />" & ChrW(13) & ChrW(10) & "            <xs:enumeration value=""Started"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ExtractListType"">" & ChrW(13) & ChrW(10) & "        <xs:choice minOccurs=""0"" maxOccurs=""unbounded"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""ActivityDataTrackingExtract"" type=""ActivityDataTrackingExtractType"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""WorkflowDataTrackingExtract"" type=""WorkflowDataTrackingExtractType"" />" & ChrW(13) & ChrW(10) & "        </xs:choice>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""ActivityDataTrackingExtractType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence minOccurs=""1"" maxOccurs=""1"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""Member"" type=""xs:string"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:complexType name=""WorkflowDataTrackingExtractType"">" & ChrW(13) & ChrW(10) & "        <xs:sequence minOccurs=""1"" maxOccurs=""1"">" & ChrW(13) & ChrW(10) & "            <xs:element name=""Member"" type=""xs:string"" minOccurs=""1"" maxOccurs=""1"" />" & ChrW(13) & ChrW(10) & "            <xs:element name=""Annotations"" type=""AnnotationListType"" minOccurs=""0"" maxOccurs=""unbounded"" />" & ChrW(13) & ChrW(10) & "        </xs:sequence>" & ChrW(13) & ChrW(10) & "    </xs:complexType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""VersionType"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:pattern value=""(^(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))$)|(^(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))$)|(^(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))\.(0*([0-9]\d{0,8}|[1-2][0-1][0-4][0-7][0-4][0-8][0-3][0-6][0-4][0-7]))$)"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & ChrW(13) & ChrW(10) & "    <xs:simpleType name=""NonNullString"">" & ChrW(13) & ChrW(10) & "        <xs:restriction base=""xs:string"">" & ChrW(13) & ChrW(10) & "            <xs:minLength value=""1"" />" & ChrW(13) & ChrW(10) & "        </xs:restriction>" & ChrW(13) & ChrW(10) & "    </xs:simpleType>" & ChrW(13) & ChrW(10) & "</xs:schema>"
    End Class
End Namespace

